package com.kinon.gfcanteen_v1.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.kinon.gfcanteen_v1.app.MyApp;

/**
 * Created by lhqq on 2018-01-09.
 */

public class SPManager {

    private static  SPManager mSpManager=null;
    private static SharedPreferences mSp=null;
    private static SharedPreferences.Editor mEditor=null;

    private final String GFV1_APP="usergf_v1";

    public static SPManager getInstance(){
        if(mSpManager==null || mSp==null || mEditor==null){
          mSpManager=new SPManager();
        }
        return mSpManager;
    }

    public SPManager() {
        mSp= MyApp.getInstance().getSharedPreferences
                (GFV1_APP, Context.MODE_APPEND);
        mEditor=mSp.edit();
    }

    public String getToken(){
        return mSp.getString("token","");
    }
    public void putStr(String key,String value){
        mEditor.putString(key,value);
    }
    public String getStr(String key){
        return mSp.getString(key,"");
    }
    public void commit(){
        mEditor.commit();
    }
    /**清空sp里面的内容*/
    public void removesp(){
        mEditor.clear();
        mEditor.commit();
    }
}
